//
//  ViewController.m
//  MyFisrstXib
//
//  Created by lanou3g on 14-12-6.
//  Copyright (c) 2014年 lanou3g. All rights reserved.
//

#import "ViewController.h"
#import "HHCell.h"
@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>

@end

@implementation ViewController

-(void)createView
{
    _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 320,568 ) style:UITableViewStylePlain];
    _tableView.dataSource = self;
    _tableView.delegate = self;
    [self.view addSubview:_tableView];
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 10;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *iden = @"cell";
    HHCell *cell = [tableView dequeueReusableCellWithIdentifier:iden];
    
    if (!cell) {
        cell = [[[NSBundle mainBundle]loadNibNamed:@"HHCell" owner:nil options:nil]firstObject];
        
        cell.selectionStyle = NO;
        
    }
    [cell.imageButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [cell.imageButton setTitle:@"-.-" forState:UIControlStateNormal];
    return cell;
    
}

-(void)buttonAction:(id)sender
{
    NSLog(@"nimei");
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 100;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self createView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
